package com.shenchuangit.rydemo.web.activitis.utils;

import com.ruoyi.activiti.listener.ActivitiDefaultEventListener;
import org.activiti.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * spring boot 启动监听类
 * @author dpf
 */
@Component
public class ApplicationPreparedEventListener implements ApplicationListener<ContextRefreshedEvent> {
    @Autowired
    private ActivitiDefaultEventListener activitiDefaultEventListener;
    @Autowired
    private RuntimeService runtimeService;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        System.out.println("ApplicationPreparedEventListener");
        this.runtimeService.addEventListener(activitiDefaultEventListener);
    }
}
